<?php	require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('navigation_list');

/*
**************************
(C)2010-2014 phpMyWind.com
update: 2011-5-5 20:06:22
person: Feng
**************************
*/

//初始化参数
$tbname = '#@__navigation';
$gourl  = 'navigation.php';
$action = isset($action) ? $action : '';
$checkinfo = isset($checkinfo) ? $checkinfo : 'false';
$action_type = isset($action_type) ? $action_type : '';
$RBAC = isset($RBAC) ? $RBAC : 'false';

	//引入操作类
require_once(ADMIN_INC.'/action.class.php');

if($action == 'add')
{		


	$parentstr = $doaction->GetParentStr();
	
	//权限属性
	if(is_array($action_type))
	{
		$action_type = implode(',',$action_type);
	}


	$sql = "INSERT INTO `$tbname` (parentid, parentstr, classname, linkurl, idname, picurl, remark, orderid, checkinfo,RBAC, action_type) VALUES ('$parentid','$parentstr', '$classname', '$linkurl', '$idname', '$picurl', '$remark', '$orderid', '$checkinfo', '$RBAC','$action_type')";
	if($dosql->ExecNoneQuery($sql))
	{
		header("location:$gourl");
		exit();
	}
}

//修改导航菜单
else if($action == 'update')
{

	$parentstr = $doaction->GetParentStr();


	//不允许更新parentid为自己
	if($parentid != $id)
	{
		//更新所有关联parentstr
		if($parentid != $repid)
		{
			//更新下级parentstr
			$doaction->UpParentStr($id);
		}
		
		//权限属性
			if(is_array($action_type))
			{
				$action_type = implode(',',$action_type);
			}

		$sql = "UPDATE `$tbname` SET  parentid='$parentid', parentstr='$parentstr', classname='$classname', linkurl='$linkurl', idname='$idname', picurl='$picurl', remark='$remark', orderid='$orderid', checkinfo='$checkinfo',RBAC='$RBAC',action_type='$action_type' WHERE id=$id";
		if($dosql->ExecNoneQuery($sql))
		{
			header("location:$gourl");
			exit();
		}
	}
	else
	{
		Msg('不允许选择本身作为所属父类！');
		exit();
	}
}


//无条件返回
else
{
    header("location:$gourl");
	exit();
}
?>